-- FreeSWITCH directory lua exmaple
-- QQ: 1053481745
freeswitch.consoleLog("notice", "Debug from gen_dir_user_xml.lua, provide params:\n"..params:serialize().."\n")                                                 
local req_domain = params:getHeader("domain")
local req_key = params:getHeader("key")
local req_user = params:getHeader("user")
if req_user==nil then
    req_user="1001";
end
XML_STRING =
[[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
    <section name="directory">
    <domain name="]]..req_domain..[[">
    <user id="]]..req_user..[[">
        <params>
            <param name="password" value="123456"/>
            <param name="vm-password" value="]]..req_user..[["/>
            <param name="dial-string" value="{sip_invite_domain=${dialed_domain},presence_id=$={dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}"/>
        </params>
        <variables>
        <variable name="toll_allow" value="domestic, international,local"/>
        <param name="accountcode" value="]]..req_user..[["/>
        <variable name="user_context" value="default"/>
        <param name="effective_caller_id_number" value="]]..req_user..[["/>
        <param name="effective_caller_id_name" value="Extension]]..req_user..[["/>
        <variable name="outbound_caller_id_name" value="Extension 5678"/>
        <variable name="outbound_caller_id_number" value="5678"/>
        <variable name="callgroup" value="techsupport"/>
    </variables>
        </user>
    </domain>
    </section>
</document>]]
--commment the following line for production:
freeswitch.consoleLog("notice", "Debug from gen_dir_user_xml.lua, generated XML:\n"..XML_STRING.."\n")
